package app;

import app.server.NettyHttpServer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class NettyHttpStart implements CommandLineRunner {

    private static final Logger logger = LoggerFactory.getLogger(NettyHttpStart.class);

    @Autowired
    NettyHttpServer server;

    // 此种方式初始化server不好用！
//    @Autowired
//    void init() {
//        server.start();
//    }

    public static void main(String[] args) {
        SpringApplication.run(NettyHttpStart.class, args);
    }

    @Override
    public void run(String... args) {
        // 只有这样才好用！
        server.start();
    }
}
